﻿package mortal.game.view.copy.crossMainCity.panels.sub
{
    import Message.Public.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.*;
    import mortal.game.view.copy.crossMainCity.panels.*;
    import mortal.game.view.mainUI.smallMap.view.*;
    import mortal.mvc.core.*;

    public class MainCityBattleCopyInfoBase extends CopyInfoPanelBase
    {
        protected var _bg:GImageBitmap;
        protected var _leftTime:SecTimerView;
        protected var _smallMap:SmallMapEmbedView;
        protected var _btnExit:GLoadingButton;
        protected var _txtRank:GTextFiled;
        protected var _txtTips:GTextFiled;
        protected var _loaded:Boolean = false;
        protected var _txtRules:GTextFiled;
        private var _index:int = -1;

        public function MainCityBattleCopyInfoBase(param1:String = "", param2:int = 250, param3:int = 380, param4:int = 6)
        {
            super(ImagesConst.copyInfoPanelTitleMainCity, 262, 588, param4);
            return;
        }// end function

        public function updateLeftTime(param1:int = 900) : void
        {
            var _loc_2:SPublicCopyOpen = null;
            var _loc_3:int = 0;
            if (_loc_2 == null)
            {
                this._leftTime.setLeftTime(param1);
            }
            else
            {
                _loc_3 = (_loc_2.endDt.time - ClockManager.instance.nowDate.time) / 1000;
                this._leftTime.setLeftTime(_loc_3);
            }
            return;
        }// end function

        protected function timerOutHandler() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._leftTime.stop();
            return;
        }// end function

        private function onClickExit(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyClickQuickBtn));
            return;
        }// end function

        protected function clickRankHandler(param1 = null) : void
        {
            if (CopyUtil.isInMainCityBattleFinalCopy)
            {
                GameProxy.copy.crossMainCityGetFinalRank();
            }
            else
            {
                GameProxy.copy.crossMainCityGetKORank();
            }
            return;
        }// end function

        private function test() : void
        {
            var _loc_4:String = this;
            var _loc_5:* = this._index + 1;
            _loc_4._index = _loc_5;
            var _loc_1:* = new MainCityRankPanel();
            _loc_1.show();
            var _loc_2:Array = [];
            var _loc_3:int = 0;
            if (this._index == 0)
            {
                _loc_1.changeToTabIndex(MainCityRankPanel.Index_Total);
                _loc_3 = 0;
                while (_loc_3 < 50)
                {
                    
                    _loc_2.push(null);
                    _loc_3++;
                }
                _loc_1.updateRankDatas(_loc_2);
            }
            else if (this._index == 1)
            {
                _loc_1.changeToTabIndex(MainCityRankPanel.Index_MyGuild);
                _loc_3 = 0;
                while (_loc_3 < 28)
                {
                    
                    _loc_2.push(null);
                    _loc_3++;
                }
                _loc_1.updateRankDatas(_loc_2);
            }
            else
            {
                _loc_1.changeToTabIndex(MainCityRankPanel.Index_EnemysGuild);
                _loc_3 = 0;
                while (_loc_3 < 22)
                {
                    
                    _loc_2.push(null);
                    _loc_3++;
                }
                _loc_1.updateRankDatas(_loc_2);
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap(null, 0, 0, _bodySprite);
            LoaderHelp.setBitmapdata(ImagesConst.MainCityCopyInfoBg + ".swf", this._bg);
            this._leftTime = UIFactory.secTimeView(Language.getString(20924), 95, 260, 120, 22, _bodySprite, GlobalStyle.textFormatLv);
            this._leftTime.timeOutHandler = this.timerOutHandler;
            this._leftTime.filters = [FilterConst.glowFilter];
            this._smallMap = UIFactory.smallMapEmbedView(ImagesConst.ZZXYBattleMiniMap, 16, 44, _bodySprite, true);
            this._smallMap.run();
            this._txtRank = UIFactory.gTextField("", 28, 215, 200, 22, _bodySprite);
            this._txtRank.mouseEnabled = true;
            this._txtRank.htmlText = Language.getString(20925);
            this._txtRank.configEventListener(TextEvent.LINK, this.clickRankHandler);
            this._txtRules = UIFactory.gTextField("", this._txtRank.x + 160, this._txtRank.y, 110, 22, _bodySprite);
            this._txtRules.mouseEnabled = true;
            this._txtRules.htmlText = Language.getString(20926);
            this._txtRules.configEventListener(TextEvent.LINK, this.showRuleWin);
            this._txtTips = UIFactory.gTextField("", 26, this._leftTime.y + 27, 260, 120, _bodySprite);
            this._txtTips.textColor = 16777215;
            this._txtTips.multiline = true;
            this._txtTips.wordWrap = true;
            this._txtTips.htmlText = "";
            this._btnExit = UIFactory.gLoadingButton(ResFileConst.ExitCopyBtn, 81, 523, 103, 38, _bodySprite);
            this._btnExit.configEventListener(MouseEvent.CLICK, this.onClickExit);
            LoaderHelp.addResCallBack(ResFileConst.mainCityCopyInfo, this.resLoaded);
            return;
        }// end function

        protected function showRuleWin(param1) : void
        {
            if (CopyUtil.isInMainCityBattleFinalCopy)
            {
                MainCityBattleFinalRuleWin.instance.show();
            }
            else
            {
                MainCityBattleKORuleWin.instance.show();
            }
            return;
        }// end function

        protected function resLoaded() : void
        {
            this._loaded = true;
            this.updateResImg();
            return;
        }// end function

        protected function updateResImg() : void
        {
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._bg = null;
            this._leftTime.dispose(param1);
            this._leftTime = null;
            this._smallMap.dispose(param1);
            this._smallMap = null;
            this._txtRank.dispose(param1);
            this._txtRank = null;
            this._txtTips.dispose(param1);
            this._txtTips = null;
            this._btnExit.dispose(param1);
            this._btnExit = null;
            this._loaded = false;
            this._txtRules.dispose(param1);
            this._txtRules = null;
            return;
        }// end function

    }
}
